Breaking Bad - A Tale of Descent into Darkness¶

Breaking Bad is an American television series that aired from 2008 to 2013, created by Vince Gilligan. It is widely regarded as one of the greatest television series of all time and has garnered critical acclaim for its writing, acting, and cinematography.

Breaking Bad follows the story of Walter White, a high school chemistry teacher living in Albuquerque, New Mexico. Walter's life takes a drastic turn when he is diagnosed with terminal lung cancer, leaving him with only a few years to live. Faced with the prospect of leaving his family in financial ruin, Walter decides to use his chemistry expertise to cook and sell methamphetamine in order to secure their financial future.

As Walter delves deeper into the world of drug manufacturing, he teams up with his former student, Jesse Pinkman, a small-time methamphetamine producer and dealer. Together, they embark on a journey filled with danger, moral ambiguity, and unexpected consequences.

The series explores themes of morality, identity, and the consequences of one's actions. As Walter becomes increasingly involved in the criminal underworld, he grapples with his own morality and the impact of his choices on those around him. His transformation from a mild-mannered teacher to a ruthless drug lord is a central focus of the show.

Breaking Bad is known for its complex characters, intricate plot twists, and intense storytelling. It features standout performances from actors such as Bryan Cranston as Walter White, Aaron Paul as Jesse Pinkman, and Anna Gunn as Walter's wife, Skyler White.

Throughout its five-season run, Breaking Bad captivated audiences with its gripping narrative and stunning visuals. It received numerous awards and accolades, including 16 Primetime Emmy Awards.

With its unforgettable characters, gripping storyline, and thought-provoking themes, Breaking Bad remains a landmark achievement in television history, solidifying its place as a modern classic.

Breaking Bad

Data Collection and Collected Columns¶

The data for this analysis was collected from various sources, including official episode guides, IMDb, and Wikipedia. The dataset includes information about each episode of the TV show "Breaking Bad," including details such as the episode number, title, director, writer, original air date, and US viewership.

The following table provides a description of each collected column:

Variable Description
number_overall The overall episode number in the entire series.
number_in_season The episode number within a particular season.
title The title of the episode.
directed_by The director(s) of the episode.
written_by The writer(s) of the episode.
original_air_date The original air date of the episode.
us_viewers The number of viewers (in millions) who watched the episode during its initial US broadcast.
In [ ]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.graph_objs as go
from plotly.offline import iplot
import plotly
plotly.offline.init_notebook_mode()
In [ ]:
# Load the data
df = pd.read_csv("../data/breaking_bad_episodes.csv")

# Convert original_air_date to datetime
df['original_air_date'] = pd.to_datetime(df['original_air_date'])
In [ ]:
# Create season column
season_number = 1
prev_episode_number = 0
season_numbers = []

for index, row in df.iterrows():
    episode_number = row['number_in_season']
    
    if episode_number <= prev_episode_number:
        season_number += 1
    
    season_numbers.append(season_number)
    
    prev_episode_number = episode_number

df['season'] = season_numbers
In [ ]:
df.head(10)
Out[ ]:
number_overall number_in_season title directed_by written_by original_air_date us_viewers season
0 1 1 Pilot Vince Gilligan Vince Gilligan 2008-01-20 1.41 1
1 2 2 Cat's in the Bag... Adam Bernstein Vince Gilligan 2008-01-27 1.49 1
2 3 3 ...And the Bag's in the River Adam Bernstein Vince Gilligan 2008-02-10 1.08 1
3 4 4 Cancer Man Jim McKay Vince Gilligan 2008-02-17 1.09 1
4 5 5 Gray Matter Tricia Brock Patty Lin 2008-02-24 0.97 1
5 6 6 Crazy Handful of Nothin' Bronwen Hughes George Mastras 2008-03-02 1.07 1
6 7 7 A No-Rough-Stuff-Type Deal Tim Hunter Peter Gould 2008-03-09 1.50 1
7 8 1 Seven Thirty-Seven Bryan Cranston J. Roberts 2009-03-08 1.66 2
8 9 2 Grilled Charles Haid George Mastras 2009-03-15 1.60 2
9 10 3 Bit by a Dead Bee Terry McDonough Peter Gould 2009-03-22 1.13 2

Summary of Basic Statistics¶

In [ ]:
summary_stats = df.describe()
summary_stats
Out[ ]:
number_overall number_in_season us_viewers season
count 62.000000 62.000000 62.000000 62.000000
mean 31.500000 7.048387 2.235968 3.290323
std 18.041619 4.074822 1.674573 1.359690
min 1.000000 1.000000 0.970000 1.000000
25% 16.250000 4.000000 1.322500 2.000000
50% 31.500000 7.000000 1.650000 3.000000
75% 46.750000 10.000000 2.267500 4.750000
max 62.000000 16.000000 10.280000 5.000000

Key Observations:

  • Episode Count: The dataset comprises 62 episodes.
  • Seasons: Across the show's run, episodes are distributed unevenly, with an average of around 7 episodes per season.
  • Viewership: The average viewership is approximately 2.24 million, ranging from 0.97 million to 10.28 million.
  • Seasons: "Breaking Bad" spans 5 seasons.

These insights illuminate the show's popularity and structure, providing context for its enduring appeal.

Exploratory Data Analysis (EDA) of Breaking Bad Viewership¶

Breaking Bad captivated audiences worldwide with its gripping storyline, complex characters, and intense drama. In this EDA section, we delve into the viewership trends of the acclaimed TV series. We analyze the data to uncover patterns, trends, and notable observations regarding the show's viewership over time.

In [ ]:
# Breaking Bad colors
colors = ['#009688', '#FFC107']

# Viewership Over Time
viewership_over_time = go.Scatter(x=df['original_air_date'], y=df['us_viewers'],
                                  mode='lines+markers', name='Viewership', line=dict(color=colors[0]))

layout = go.Layout(title='Viewership of Breaking Bad Over Time',
                   xaxis=dict(title='Original Air Date'),
                   yaxis=dict(title='Viewership'),
                   hovermode='closest',
                   plot_bgcolor='#f0f0f0',
                   paper_bgcolor='#f0f0f0',
                   font=dict(color='#333333'))

fig1 = go.Figure(data=[viewership_over_time], layout=layout)
iplot(fig1)
In [ ]:
sns.set_style("darkgrid")

plt.figure(figsize=(10, 5))
sns.lineplot(data=df, x='number_overall', y='us_viewers', marker='o', color='#FFC107')
plt.title('Breaking Bad Viewership Over Time', fontsize=16)
plt.xlabel('Episode Number', fontsize=14)
plt.ylabel('U.S. Viewers (millions)', fontsize=14)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.grid(True)
plt.show()

Viewership of Breaking Bad Over Time¶

The plot below illustrates the viewership of Breaking Bad episodes over time. Here are some observations:

  • Trend: Overall, the viewership of Breaking Bad episodes tends to fluctuate throughout the series.
  • Seasonal Patterns: There are noticeable peaks and valleys in viewership, which could be attributed to various factors such as the intensity of the plot, marketing efforts, or external events.
  • Increasing Trend: Despite fluctuations, there seems to be a general increasing trend in viewership, especially towards the later seasons.
  • Seasonal Differences: Each season shows distinct patterns in viewership, with some seasons experiencing more significant fluctuations than others.
  • Episodic Changes: Viewership can vary significantly from one episode to another within the same season, indicating the impact of individual plotlines and events on audience engagement.

Overall, the plot provides insights into the popularity and audience engagement of Breaking Bad throughout its airing, highlighting the dynamic nature of viewership trends over time.

In [ ]:
df['viewership_change'] = df['us_viewers'].diff()

df['viewership_change'].fillna(0, inplace=True)

# Episode-to-Episode Changes in Viewership
episode_changes = go.Bar(x=df['number_overall'], y=df['viewership_change'],
                         marker=dict(color=colors[1]), name='Viewership Changes')

layout = go.Layout(title='Episode-to-Episode Changes in Viewership',
                   xaxis=dict(title='Episode Number'),
                   yaxis=dict(title='Viewership Change'),
                   hovermode='closest',
                   plot_bgcolor='#f0f0f0',
                   paper_bgcolor='#f0f0f0',
                   font=dict(color='#333333'))

fig2 = go.Figure(data=[episode_changes], layout=layout)

iplot(fig2)
In [ ]:
# Viewership of Breaking Bad Episodes
episode_changes = go.Bar(x=df['number_overall'], y=df['us_viewers'],
                         marker=dict(color=colors[0]), name='Viewership')

layout = go.Layout(title='Viewership of Breaking Bad Episodes',
                   xaxis=dict(title='Episode Number'),
                   yaxis=dict(title='Viewership'),
                   hovermode='closest',
                   plot_bgcolor='#f0f0f0',
                   paper_bgcolor='#f0f0f0',
                   font=dict(color='#333333'))

fig4 = go.Figure(data=[episode_changes], layout=layout)
iplot(fig4)

Episode-to-Episode Changes in Viewership¶

The bar plot below visualizes the episode-to-episode changes in viewership for Breaking Bad. Here are some observations:

  • Fluctuations: The bar heights indicate the change in viewership from one episode to the next. Positive values represent an increase in viewership, while negative values indicate a decrease.
  • Varying Magnitudes: The magnitude of changes varies from episode to episode, with some episodes experiencing significant increases or decreases in viewership compared to the previous episode.
  • Patterns: While there are fluctuations from episode to episode, certain patterns emerge, such as alternating increases and decreases in viewership over consecutive episodes.
  • Seasonal Trends: Seasonal differences in viewership changes can also be observed, with some seasons showing more consistent trends while others exhibit greater variability.

Overall, the plot provides insights into the episodic fluctuations in viewership for Breaking Bad, highlighting the dynamic nature of audience engagement with each episode.

In [ ]:
season_wise_viewership = df.groupby('season')['us_viewers'].sum().reset_index()

season_wise_viewership['viewership_change'] = season_wise_viewership['us_viewers'].diff()
season_wise_viewership['viewership_change'].fillna(0, inplace=True)

season_diffs = go.Bar(x=season_wise_viewership['season'], y=season_wise_viewership['viewership_change'],
                      marker=dict(color=colors[1]), name='Viewership Change')

layout = go.Layout(title='Season-to-Season Changes in Viewership',
                   xaxis=dict(title='Season'),
                   yaxis=dict(title='Viewership Change'),
                   hovermode='closest',
                   plot_bgcolor='#f0f0f0',
                   paper_bgcolor='#f0f0f0',
                   font=dict(color='#333333'))

fig5 = go.Figure(data=[season_diffs], layout=layout)
iplot(fig5)
In [ ]:
season_viewership = df.groupby('season')['us_viewers'].sum().reset_index()

season_changes = go.Bar(x=season_viewership['season'], y=season_viewership['us_viewers'],
                        marker=dict(color=colors[0]), name='Viewership')

layout = go.Layout(title='Season-to-Season Changes in Viewership',
                   xaxis=dict(title='Season'),
                   yaxis=dict(title='Total Viewership'),
                   hovermode='closest',
                   plot_bgcolor='#f0f0f0',
                   paper_bgcolor='#f0f0f0',
                   font=dict(color='#333333'))

fig6 = go.Figure(data=[season_changes], layout=layout)
iplot(fig6)

Season-to-Season Changes in Viewership¶

The viewership of Breaking Bad increased steadily from Season 1 to Season 5, with significant jumps observed between certain seasons:

  • Season 1 had a viewership of 8.61 million, serving as the baseline.
  • Season 2 experienced a notable increase, reaching 16.98 million viewers, indicating a viewership change of 8.37 million from the previous season.
  • Season 3 continued the upward trend, with a viewership of 19.72 million, reflecting a 2.74 million increase from Season 2.
  • Season 4 saw a substantial rise, reaching 24.27 million viewers, marking a significant increase of 4.55 million from the previous season.
  • Season 5 witnessed the highest viewership, with 69.05 million viewers, indicating a remarkable surge of 44.78 million from Season 4.

Overall, the series experienced remarkable growth in viewership over its five seasons, with Season 5 standing out as the peak in terms of audience engagement.

In [ ]:
director_counts = df['written_by'].value_counts()

plt.figure(figsize=(10, 6))
director_counts.plot(kind='bar', color=colors[0])
plt.title('Top Directors with the Most Written Episodes')
plt.xlabel('Director')
plt.ylabel('Number of Episodes Written')
plt.xticks(rotation=45, ha='right')
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()
In [ ]:
director_viewership = df.groupby('written_by')['us_viewers'].sum().sort_values(ascending=False)

plt.figure(figsize=(10, 6))
director_viewership.plot(kind='bar', color=colors[1])
plt.title('Top Directors by Total Viewership')
plt.xlabel('Director')
plt.ylabel('Total Viewership (millions)')
plt.xticks(rotation=45, ha='right')
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()
In [ ]:
avg_episodes_per_season = df.groupby('season')['number_in_season'].max().mean()

# Number of episodes per season
avg_episodes_trace = go.Bar(x=df['season'].unique(), y=df.groupby('season')['number_in_season'].max(),
                            marker=dict(color=colors[0]))
layout = go.Layout(title='Number of Episodes per Season',
                   xaxis=dict(title='Season'),
                   yaxis=dict(title='Number of Episodes'),
                   plot_bgcolor='#f0f0f0',  
                   paper_bgcolor='#f0f0f0',
                   font=dict(color='#333333'))
fig = go.Figure(data=[avg_episodes_trace], layout=layout)
iplot(fig)
In [ ]:
avg_viewership_per_episode = df.groupby('season')['us_viewers'].sum() / df.groupby('season')['number_in_season'].max()

# Average viewership per episode for each season
avg_viewership_trace = go.Bar(x=df['season'].unique(), y=avg_viewership_per_episode,
                              marker=dict(color=colors[1]))
layout = go.Layout(title='Average Viewership per Episode for Each Season',
                   xaxis=dict(title='Season'),
                   yaxis=dict(title='Average Viewership per Episode'),
                   plot_bgcolor='#f0f0f0',
                   paper_bgcolor='#f0f0f0',
                   font=dict(color='#333333'))
fig = go.Figure(data=[avg_viewership_trace], layout=layout)
iplot(fig)
In [ ]:
print(f"The viewership increased by {abs(df[df['season'] == 3]['us_viewers'].mean() - df[df['season'] == 5]['us_viewers'].mean())} between seasons 3 and 5.")
The viewership increased by 2.798701923076923 between seasons 3 and 5.

Summary Exploring Breaking Bad Viewership¶

Breaking Bad, a critically acclaimed television series created by Vince Gilligan, follows the transformation of a high school chemistry teacher, Walter White, into a ruthless drug lord. With its gripping storyline and compelling characters, Breaking Bad has captivated audiences worldwide.

Viewership Analysis¶

  • Viewership Over Time: The line plot illustrates the viewership of Breaking Bad episodes over time, showing a general increasing trend.
  • Episode-to-Episode Changes: The bar plot depicts fluctuations in viewership from one episode to the next, highlighting both increases and decreases.
  • Season-to-Season Changes: Another bar plot showcases the total viewership of each season, revealing a significant spike in viewership from Season 4 to Season 5.
  • Top Directors Analysis: Two bar plots identify the top directors based on the number of episodes they've written and the total viewership of episodes they've directed, with Vince Gilligan emerging as a prominent figure in both categories.

Through these visualizations and analyses, we gain a deeper understanding of the evolution of Breaking Bad's viewership and the contributions of its creators to its success.